// 函数对象(仿函数) 通过重载()让类看起来像函数
#include <iostream>
#include <string>
using namespace std;
class MyPrint
{
public:
    MyPrint():count(0) {}
    int count;
    void operator()(const string &text)
    {
        cout << text << endl;
        ++count;
    }
};
void doWork(MyPrint &mp, const string &text)
{
    mp(text);
}
void test1()
{
    MyPrint mp;
    mp("hello");
    mp("lxy");
    cout << mp.count << endl;
    doWork(mp, "hahaha");
}
int main(void)
{
    test1();

    return 0;
}